<template>
  <div>
    <table>
      <practise5
        v-for="(obj, index) in goodsArr"
        :key="index"
        :obj="obj"
      ></practise5>
    </table>
    <p>All Number:{{ sum }}</p>
  </div>
</template>

<script>
import practise5 from "./components/practise5";
export default {
  components: {
    practise5,
  },
  data() {
    return {
      goodsArr: [
        {
          count: 0,
          goodsName: "Watermelon",
        },
        {
          count: 0,
          goodsName: "Banana",
        },
        {
          count: 0,
          goodsName: "Orange",
        },
        {
          count: 0,
          goodsName: "Pineapple",
        },
        {
          count: 0,
          goodsName: "Strawberry",
        },
      ],
      // sum: "",/
    };
  },

  computed: {
    sum() {
      // return this.goodsArr.reduce((total, n) => total + n.count, 0);
      return this.goodsArr.reduce((sum, obj) => (sum += obj.count * 1), 0);
    },
  },
};
</script>

<style>
</style>